<?php $errorStr=$fileUrl='';if(!$_FILES){$errorStr='未接收到上传文件';}else{@set_time_limit(60);$fileSpace=new Zmsun\Copen\FileSpace($this->serviceManager);$allowExt=["jpg","jpeg","png","gif",'bmp'];$uploader=new Zmsun\Filesystem\Upload\UploadAssist();foreach($_FILES as$fieldItem){array_walk($fieldItem,function(&$val){$val=(array)$val;});foreach($fieldItem['error']as$key=>$code){if($code!=UPLOAD_ERR_OK){$errorStr.='上传失败：'.$uploader::codeToMessage($code).';';}else{$ext=pathinfo($fieldItem['name'][$key],PATHINFO_EXTENSION);if(!in_array($ext,$allowExt)){$errorStr.='不支持的图片类型：'.$fieldItem['tmp_name'][$key].';';}elseif(!$fileUrl=$fileSpace->addUploadFile($fieldItem['tmp_name'][$key],$fileSpace::DIR_ADMIN,$ext,null,uniqid("art",true).".$ext")){$errorStr.='图片'.$fieldItem['tmp_name'][$key].'保存失败;';}}}}}if($errorStr){echo json_encode(['status'=>'error','info'=>$errorStr,]);}else{echo json_encode(['status'=>'ok','info'=>$fileUrl]);}?>